<#assign ctx = request.contextPath />
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="description" content="${company.introduceContent?if_exists}"/>
    <title>${company.introduceTitle?if_exists}</title>
    <meta name="viewport" content="initial-scale=1,maximum-scale=1, minimum-scale=1"/>
    <link rel="stylesheet" href="${ctx}/assets/css/member/a.css">
    <link rel="stylesheet" href="${ctx}/assets/css/member/style.css">
    <script src="${ctx}/assets/js/member/zepto.js"></script>
</head>

<input type="hidden" id="id" name="id" value="${driver.id}"/>

<body style="text-align:center">

<div class="container" style="background-image: url('${ctx}/assets/img/member/bg_02.jpg');background-size: 100% 70%; -webkit-background-size: 100% 70%;background-repeat: no-repeat;-o-background-size: 100% 70%;background-position: center 0;">
    <div class="box" style="top: 10%">
        <div class="go">
            <input type="number" id="phone1" placeholder="请输入手机号" oninput="if(value.length>11)value=value.slice(0,11)">
            <button type="button" id="sub-phone" style="background-color: #ffd876;">马上体验</button>
        </div>
    </div>
</div>

<div class="container2">
    <div class="box">
        <h2>验证码已发送至</h2>
        <div class="getcode">
            <p id="phone"></p>
            <button type="button" class="get-code" id="get-code-btn" style="color: #ffd876">获取验证码</button>
        </div>
        <input type="number" style="border-bottom:1px solid #ffd876;border-radius: 0px;" id="code"
               oninput="if(value.length>4)value=value.slice(0,4)">
        <button type="button" class="sub-code" style="background-color: #ffd876;" id="sub-code">免费体验</button>
    </div>
</div>

<div class="container3 container31"
     style="background-image: url('${ctx}/assets/img/member/download2.png');background-repeat: no-repeat;background-size: cover;-webkit-background-size: cover;-o-background-size: cover;background-position: center 0;">
    <div class="bg-box"
    ">
    <#--<div class="code-box">-->
        <!--<img src="./img/code.jpg">-->
    <#--<#if wxsetting.wxQrCode?? && (wxsetting.wxQrCode?length>0)>-->
    <#--<img src="${ctx}/${wxsetting.wxQrCode?if_exists}">-->
    <#--<p>长按识别二维码关注公众号</p>-->
    <#--</#if>-->
    <#--</div>-->
    <#--<div class="code-box">-->
        <!--<img src="./img/code.jpg">-->
    <#--<#if wxsetting.wxSmallQrCode?? && (wxsetting.wxSmallQrCode?length>0)>-->
    <#--<img src="${ctx}/${wxsetting.wxSmallQrCode?if_exists}">-->
    <#--<p>长按识别二维码关注小程序</p>-->
    <#--</#if>-->
    <#--</div>-->
</div>
<div style="background-repeat: no-repeat;background-size: cover;padding: 2rem 0;position: fixed;width: 100%;bottom: 0;">
    <div class="app-down" id="ios_down_div">
        <div class="icon" id="ios_down_div1" style="background-image: url(${ctx}/assets/img/member/apple_001.png);background-color: white;
                background-repeat: no-repeat;background-size: cover;-webkit-background-size: cover;-o-background-size: cover;
                background-position: center 0;"></div>
        <div class="mybox" style="text-align: center;
    font-size: 5px;
    width: 4.5rem;
    position: fixed;
    bottom: 13.5%;
    right: 12%;">
            <img src="${ctx}/assets/img/member/qrcode.jpg" style="width: 100%;"></div>
    </div>
<#-- <div class="text">
   <h3>免费安装</h3>
   <p>ipone版</p>
 </div>-->

    <div class="app-down" id="and_down_div">
        <div class="icon" id="and_down_div1" style="background-image: url(${ctx}/assets/img/member/android_001.png);
                background-color: white;background-repeat: no-repeat;background-size: cover;-webkit-background-size: cover;-o-background-size: cover;
                background-position: center 0;"></div>
        <div class="mybox" style="text-align: center;
    font-size: 5px;
    width: 4.5rem;
    position: fixed;
    bottom: 13.5%;
    right: 12%;">
            <img src="${ctx}/assets/img/member/qrcode.jpg" style="width: 100%;"></div>
    </div>
</div>
<#--  <div class="text">
    <h3>免费下载</h3>
    <p>Android版</p>
  </div>-->
</div>
</div>
</div>

<div class="modal" id="modal">
    <div class="box">
        <p id="msg"></p>
        <div class="btn">
            <button type="button" id="modal-btn">确认</button>
        </div>
    </div>
</div>

</body>
<script>
    // function clickMyImg(obj) {
    //     if (obj.style.width == '5rem') {
    //         obj.style.width = '100%';
    //         obj.style.right = '0';
    //     } else {
    //         obj.style.width = '5rem';
    //         obj.style.right = '12%';
    //     }
    // }
    console.log("222");

    var HEIGHT = $('body').height();
    $(window).resize(function() {
        $('body').height(HEIGHT);
    });
    function resize() {
        document.documentElement.style.fontSize = document.documentElement.clientWidth / 25 + 'px';
    }

    window.onresize = resize

    window.onload = resize

    $('.container2, .container3').hide()
    $('#modal').hide()
    $('#and_down_div').hide()
    $('#ios_down_div').hide()



    $('#sub-phone').click(function () {
        var phone = $('#phone1').val()
        var isphone = /^[0-9]{1,15}$/;
        if (phone == '' || phone.length != 11 || !isphone.test(phone)) {
            $('#msg').html('手机号错误')
            $('#modal').show()
            $('#phone1').attr('readonly', true)
            return
        }
        $('.container, .container3').hide()
        $('.getcode p').html($('.go input').val())
        $('.container2').show()
        // $('#get-code-btn').click()
    })


    //---------------------------------------------------------------------------------

    $('#modal-btn').click(function () {
        javascript:$('#modal').hide()
        $('#phone1').removeAttr('readonly')
    })

    // 获取验证码倒数计时
    function smsOverTime(t) {
        var howlong = t;

        howlong--;
        $("#get-code-btn").html(howlong);

        var timeID = setTimeout("smsOverTime(" + howlong + ")", 1000);
        if (howlong <= 0) {
            clearTimeout(timeID);
            $("#get-code-btn").html("获取验证码");
            $("#get-code-btn").attr("disable", false);
        }

    }

    // 点击获取验证码
    $('#get-code-btn').click(function () {
        if ($('#get-code-btn').attr("disable") == 'true') {
            return
        }

        // 获取手机号
        var phone = $('#phone').html();
        var isphone = /^[0-9]{1,15}$/;
        if (phone == '' || phone.length != 11 || !isphone.test(phone)) {
            $('#msg').html('手机号错误')
            $('#modal').show()
            return
        }

        // 获取公司ID
        var companyId = $("#companyId").val()
        if (companyId == '' || companyId == 0) {
            $('#msg').html('公司信息错误')
            $('#modal').show()
            return
        }

        // 获取推荐人ID
        var introducerId = $("#id").val()
        if (introducerId == '' || introducerId == 0) {
            $('#msg').html('用户信息获取失败')
            $('#modal').show()
            return
        }

        // 发送验证码
        $('#get-code-btn').attr("disable", true);
        $.get('${ctx}/driver/api/rest/v3/smsQrCode', {
            'phone': phone,
            'driverIntroducerId': introducerId
        }, function (result) {
            if (result.success) {
                smsOverTime(120);

            } else {

                if (result.errorcode == "0") {

                    smsOverTime(result.object);

                } else if (result.errorcode == "1") {
                    $('#msg').html('发送失败')
                    $('#modal').show()
                    $("#get-code-btn").attr("disable", false);
                }
            }
        }, 'json');
    })

    // 提交验证验证码，并跳转下载页面
    $('#sub-code').click(function () {

        if ($(".sub-code").attr("disable") == "true") {
            return
        }
        var phone = $('#phone').html();
        var isphone = /^[0-9]{1,15}$/;
        if (phone == '' || phone.length != 11 || !isphone.test(phone)) {
            $('#msg').html('手机号错误')
            $('#modal').show()
            return
        }

        var code = $("#code").val();
        if (code == "" || code.length != 4) {
            $('#msg').html('验证码错误')
            $('#modal').show()
            return
        }

        var id = $("#id").val()
        if (id == '' || id == 0) {
            $('#msg').html('用户信息获取失败')
            $('#modal').show()
            return
        }

        var params = {phone: phone, code: code, id: id}

        $(".sub-code").attr("disable", true);
        $.post('${ctx}/driver/api/rest/v3/downloadShareQrCode', params, function (data) {
            if (data.success) {
                zdxz(data.map.androidUrl, data.map.iosUrl);
            } else {
                $(".sub-code").attr("disable", false);
                $('#msg').html(data.message)
                $('#modal').show()
            }
        }, 'json');
    })

    function is_weixin() {
        var ua = navigator.userAgent.toLowerCase();
        if (ua.match(/MicroMessenger/i) == "micromessenger") {
            return true;
        } else {
            return false;
        }
    }

    function is_qq() {
        var ua = navigator.userAgent.toLowerCase();
        if (ua.match(/MQQBrowser/i) == "mqqbrowser") {
            return true;
        } else {
            return false;
        }
    }

    var browser = {
        versions: function () {
            var u = navigator.userAgent, app = navigator.appVersion;
            return {//移动终端浏览器版本信息 
                trident: u.indexOf('Trident') > -1, //IE内核
                presto: u.indexOf('Presto') > -1, //opera内核
                webKit: u.indexOf('AppleWebKit') > -1, //苹果、谷歌内核
                gecko: u.indexOf('Gecko') > -1 && u.indexOf('KHTML') == -1, //火狐内核
                mobile: !!u.match(/AppleWebKit.*Mobile.*/) || !!u.match(/AppleWebKit/), //是否为移动终端
                ios: !!u.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/), //ios终端
                android: u.indexOf('Android') > -1 || u.indexOf('Linux') > -1, //android终端或者uc浏览器
                iPhone: u.indexOf('iPhone') > -1 || u.indexOf('Mac') > -1, //是否为iPhone或者QQHD浏览器
                iPad: u.indexOf('iPad') > -1, //是否iPad
                webApp: u.indexOf('Safari') == -1 //是否web应该程序，没有头部与底部
            };
        }(),
        language: (navigator.browserLanguage || navigator.language).toLowerCase()
    }


    function zdxz(androidUrl, iosUrl) {
        $('.container2, .container1').hide();
        $('.container3').show();
        // console.log(iosUrl);
        // console.log(androidUrl);
        if (browser.versions.ios || browser.versions.iPhone || browser.versions.iPad) {
            $("#ios_down_div").show();
            // if (iosUrl && iosUrl != "") {
            //     $("#ios_down_div").click(function () {
            //         window.location = iosUrl;
            //     });
            // } else {
            $("#ios_down_div1").click(function () {
                $('#msg').html('苹果还没上线!');
                $('#modal').show();
            });
           
            // }

        } else if (browser.versions.android) {

            // if (androidUrl && androidUrl != "") {
            $("#and_down_div").show();
            $("#and_down_div1").click(function () {
                window.location = '${ctx}/download/customer.html';
            });
            // }
        }
    }

</script>


<!--<script src="${ctx}/assets/js/jquery-1.11.0.min.js" type="text/javascript"></script>
	  <script src="${ctx}/assets/js/bootstrap.min.js" type="text/javascript"></script>
	  <script src="${ctx}/assets/js/sco.message.js" type="text/javascript"></script>
	  <script>
	  	$(document).ready(function(){
	  	
	  			$("#qrcode").height($("#qrcode").width() + "px")

	  			// 隐藏所有
	  			$("#weixin_download").hide()
	  			$("#ios_down_div").hide();
	  			$("#and_down_div").hide();
	  			$("#weixin_qq").hide();
	  			$("#getApp").hide();
	  			
	  			// 判断显示
	  			if (is_weixin()) {
	  				$("#weixin_qq").show()
	  			} else {
	  				$("#getApp").show();
	  			}
	  	
				//表单提交
				$("#submit_button").click(function(){
					
					var phone = $("#phone").val();
					var isphone=/^[0-9]{1,15}$/; 
					if (!isphone.test(phone)){
						$.scojs_message("请填写正确的手机号码！", $.scojs_message.TYPE_ERROR);
						return;
					}
					
					var code = $("#code").val();
					if (code == "" || code.length != 4){
						$.scojs_message("请填写正确的验证码！", $.scojs_message.TYPE_ERROR);
						return;
					}
					
					
					var params = {phone:phone,code:code,id:$("#id").val()}
					
					$("#submit_button").attr("disabled",true);
					$.post('${ctx}/driver/api/rest/v3/downloadShareQrCode',params,function(data){
						if(data.success){
							$("#phone").val("");
							$("#code").val("");
							zdxz(data.map.androidUrl,data.map.iosUrl);
						}
						else{
							$("#submit_button").attr("disabled",false);
							$.scojs_message(data.message, $.scojs_message.TYPE_ERROR);
						}
					});
				
				});
				
				$("#getCode").click(function(){
					if($("#getCode").attr("disable")=="false"){
						var phone = $("#phone").val();
						if (phone == "" || phone.length != 11){
							$.scojs_message("请填写正确的手机号码！", $.scojs_message.TYPE_ERROR);
							return;
						}
					
					
						$("#getCode").attr("disable",true);
						$.get('${ctx}/driver/api/rest/v3/smsQrCode',{'phone':phone,'driverIntroducerId':$("#id").val()},function(result){
							if(result.success){
								$.scojs_message("验证码已发送成功", $.scojs_message.TYPE_OK);
								smsOverTime(120);
							}
							else{
								if(result.errorcode=="0"){
									smsOverTime(result.object);
								}
								else if(result.errorcode=="1"){
									$.scojs_message("短信发送失败，请稍后再试", $.scojs_message.TYPE_ERROR);
									$("#getCode").attr("disable",false);
								}
							}
						});
					}
				});
				
				
				var height=$(document).height();
				$("#bg_img").css({"height":height+"px"});
				
				$("#phone").click(function(){
					$(".nav").css("bottom","10%");
				}).blur(function(){
					$(".nav").css("bottom","60px");
				});
				
				$("#code").click(function(){
					$(".nav").css("bottom","10%");
				}).blur(function(){
					$(".nav").css("bottom","60px");
				});
				
			});
			
			function smsOverTime(t){
				var howlong=t;
				
				howlong--;
				$("#getCode").html(howlong);
				
				var timeID=setTimeout("smsOverTime("+howlong+")",1000);
				if(howlong<=0){
					clearTimeout(timeID);
					$("#getCode").html("获取验证码");
					$("#getCode").attr("disable",false);
				}
				
			}
			
			function is_weixin(){
				var ua = navigator.userAgent.toLowerCase();
				if(ua.match(/MicroMessenger/i)=="micromessenger") {
					return true;
				} else {
					return false;
				}
			}
			
			function is_qq(){
				var ua = navigator.userAgent.toLowerCase();
				if(ua.match(/MQQBrowser/i)=="mqqbrowser") {
					return true;
				} else {
					return false;
				}
			}
			
		    var browser = {
                versions: function() {
                    var u = navigator.userAgent, app = navigator.appVersion;
                    return {//移动终端浏览器版本信息 
                        trident: u.indexOf('Trident') > -1, //IE内核
                        presto: u.indexOf('Presto') > -1, //opera内核
                        webKit: u.indexOf('AppleWebKit') > -1, //苹果、谷歌内核
                        gecko: u.indexOf('Gecko') > -1 && u.indexOf('KHTML') == -1, //火狐内核
                        mobile: !!u.match(/AppleWebKit.*Mobile.*/) || !!u.match(/AppleWebKit/), //是否为移动终端
                        ios: !!u.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/), //ios终端
                        android: u.indexOf('Android') > -1 || u.indexOf('Linux') > -1, //android终端或者uc浏览器
                        iPhone: u.indexOf('iPhone') > -1 || u.indexOf('Mac') > -1, //是否为iPhone或者QQHD浏览器
                        iPad: u.indexOf('iPad') > -1, //是否iPad
                        webApp: u.indexOf('Safari') == -1 //是否web应该程序，没有头部与底部
                    };
                }(),
                language: (navigator.browserLanguage || navigator.language).toLowerCase()
            }
		    
			
			function zdxz(androidUrl,iosUrl){
				if(is_weixin()){
					window.location="${ctx}/driver/api/rest/v3/appXiazai";
			 	}
			 	else{
			 		if (browser.versions.ios || browser.versions.iPhone || browser.versions.iPad) {
			  			
			  			$("#weixin_qq").hide();
	  					$("#getApp").hide();
	  					$("#weixin_download").show();
	  					
	  					if (androidUrl && androidUrl != "") {
	  						$("#and_down_div").show();
	  						$("#and_down_div").click(function () {
	  							$.scojs_message("操作成功,准备开始下载客户端APP", $.scojs_message.TYPE_OK);
	  							window.location = androidUrl;
	  						})
	  					}
	  					
	  					if (iosUrl && iosUrl != "") {
	  						$("#ios_down_div").show();
	  						$("#ios_down_div").click(function () {
	  							$.scojs_message("操作成功,准备开始下载客户端APP", $.scojs_message.TYPE_OK);
	  							window.location = iosUrl
	  						})
	  					}
	  					
					}
					else if (browser.versions.android) {
					
						$("#weixin_qq").hide();
	  					$("#getApp").hide();
	  					$("#weixin_download").show();
	  					
	  					if (androidUrl && androidUrl != "") {
	  						$("#and_down_div").show();
	  						$("#and_down_div").click(function () {
	  							$.scojs_message("操作成功,准备开始下载客户端APP", $.scojs_message.TYPE_OK);
	  							window.location = androidUrl;
	  						})
	  					}
	  					
	  					if (iosUrl && iosUrl != "") {
	  						$("#ios_down_div").show();
	  						$("#ios_down_div").click(function () {
	  							$.scojs_message("操作成功,准备开始下载客户端APP", $.scojs_message.TYPE_OK);
	  							window.location = iosUrl
	  						})
	  					}
					}
			 	}
			}
			
	    </script>-->
</html>